package com.imooc.module.reponse;

/**
 * @Author Tim
 * @Description:
 * @Version 1.0
 */
public class Response<T> {

    public static final Integer SUCCESS_CODE = 200;
    public static final String SUCCESS_MSG = "操作成功";

    protected T data;
    protected Integer code;
    protected String msg;

    public Response(){

    }

    public Response(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Response<T> buildError(Integer code, String message) {
        return new Response<>(code, message, null);
    }

    public static <T> Response<T> buildSuccess(T data) {
        return new Response<>(SUCCESS_CODE, SUCCESS_MSG, data);
    }
}
